<?php
/**
 *
 * User: wufeng
 * Date: 2020/01/08
 */
namespace app\xcxapi\controller\v1;

use app\common\controller\XcxController;
use app\xcxapi\service\CourseService;

class Course extends XcxController
{
	/**
	 * 课程
	 * User: wufeng
	 * Date: 2020/01/08
	 *
	 */
	public function courseLists()
	{
		if ($this->request->isPost()) {
			$params = $this->request->param();
			$list = (new CourseService($this->type))->courseLists($params);
			if (1 !== $list['code']) {
				$this->fail($list);
			}
			$this->win($list);
		}
		$this->fail('ILLEGAL_REQUEST');
	}

	/**
	 * 新增课程
	 * User: wufeng
	 * Date: 2020/01/11
	 *
	 */
	public function courseAdd()
	{
		if ($this->request->isPost()) {
			$params = $this->request->param();
			$list = (new CourseService($this->type))->courseAdd($params);
			if (1 !== $list['code']) {
				$this->fail($list);
			}
			$this->win($list);
		}
		$this->fail('ILLEGAL_REQUEST');
	}

	/**
	 * 编辑课程
	 * User: wufeng
	 * Date: 2020/01/11
	 *
	 */
	public function coursEdit()
	{
		if ($this->request->isPost()) {
			$params = $this->request->param();
			$list = (new CourseService($this->type))->coursEdit($params);
			if (1 !== $list['code']) {
				$this->fail($list);
			}
			$this->win($list);
		}
		$this->fail('ILLEGAL_REQUEST');
	}

	/**
	 * 课程 启用/禁用
	 * User: wufeng
	 * Date: 2020/01/08
	 *
	 */
	public function courseStatus()
	{
		if ($this->request->isPost()) {
			$params = $this->request->param();
			$list = (new CourseService($this->type))->courseStatus($params);
			if (1 !== $list['code']) {
				$this->fail($list);
			}
			$this->win($list);
		}
		$this->fail('ILLEGAL_REQUEST');
	}

	/**
	 * 删除课程
	 * User: wufeng
	 * Date: 2020/01/11
	 *
	 */
	public function courseDel()
	{
		if ($this->request->isPost()) {
			$params = $this->request->param();
			$list = (new CourseService($this->type))->courseDel($params);
			if (1 !== $list['code']) {
				$this->fail($list);
			}
			$this->win($list);
		}
		$this->fail('ILLEGAL_REQUEST');
	}

	/**
	 * 课程详情/班级列表/课程目录
	 * User: wufeng
	 * Date: 2020/02/10
	 *
	 */
	public function courseDetail()
	{
		if ($this->request->isPost()) {
			$params = $this->request->param();
			$list = (new CourseService($this->type))->courseDetail($params);
			if (1 !== $list['code']) {
				$this->fail($list);
			}
			$this->win($list);
		}
		$this->fail('ILLEGAL_REQUEST');
	}

	/**
	 * 年级/科目/期段/类型/班型/计费规则/
	 * User: wufeng
	 * Date: 2020/02/10
	 *
	 */
	public function achieveLists()
	{
		if ($this->request->isPost()) {
			$list = (new CourseService($this->type))->achieveLists();
			if (1 !== $list['code']) {
				$this->fail($list);
			}
			$this->win($list);
		}
		$this->fail('ILLEGAL_REQUEST');
	}

	/**
	 * 新增课程目录
	 * User: wufeng
	 * Date: 2020/02/11
	 *
	 */
	public function scheduleAdd()
	{
		if ($this->request->isPost()) {
			$params = $this->request->param();
			$list = (new CourseService($this->type))->scheduleAdd($params);
			if (1 !== $list['code']) {
				$this->fail($list);
			}
			$this->win($list);
		}
		$this->fail('ILLEGAL_REQUEST');
	}
	
	/**
	 * 删除课程目录
	 * User: wufeng
	 * Date: 2020/04/19
	 *
	 */
	public function scheduleDel()
	{
		if ($this->request->isPost()) {
			$params = $this->request->param();
			$list = (new CourseService($this->type))->scheduleDel($params);
			if (1 !== $list['code']) {
				$this->fail($list);
			}
			$this->win($list);
		}
		$this->fail('ILLEGAL_REQUEST');
	}

	/**
	 * 编辑课程目录
	 * User: wufeng
	 * Date: 2020/02/11
	 *
	 */
	public function scheduleEdit()
	{
		if ($this->request->isPost()) {
			$params = $this->request->param();
			$list = (new CourseService($this->type))->scheduleEdit($params);
			if (1 !== $list['code']) {
				$this->fail($list);
			}
			$this->win($list);
		}
		$this->fail('ILLEGAL_REQUEST');
	}
}